//
//  YBEarnViewController+LayoutConstraints.m
//  Nectar
//
//  Created by famer on 2023/11/10.
//  Copyright © 2023 asance. All rights reserved.
//

#import "YBEarnViewController+LayoutConstraints.h"
#import "YBNavigationBar.h"
#import "YBTransferInEarnView.h"
#import "YBInviteEarnView.h"

@implementation YBEarnViewController (LayoutConstraints)

- (void)setLayoutConstraints{
    CGFloat width = self.view.size.width;
    CGFloat height = self.view.size.height;
    CGFloat leftMargin = 12;
    
    self.navigationBar.frame = CGRectMake(0,  [UIView statusBarHeight], width, 64);
    
    CGFloat scrollViewWidth = width-leftMargin*2;
    CGFloat earnViewWidht = scrollViewWidth-leftMargin;
    CGFloat earnViewHeight = [self.todayEarnBronzeView getViewHeightFromSpecialWidth:earnViewWidht];
    self.myScrollView.frame = CGRectMake(leftMargin, self.navigationBar.bottom+10, scrollViewWidth, earnViewHeight);
    
    self.todayEarnBronzeView.frame = CGRectMake(0,
                                                0,
                                                earnViewWidht,
                                                earnViewHeight);
    
    self.todayEarnGoldView.frame = CGRectMake(self.todayEarnBronzeView.right+leftMargin*1,
                                              0,
                                              earnViewWidht,
                                              earnViewHeight);
    
    self.todayEarnPlatinumView.frame = CGRectMake(self.todayEarnGoldView.right+leftMargin*1,
                                                  0,
                                                  earnViewWidht,
                                                  earnViewHeight);
    
    self.todayEarnDiamondView.frame = CGRectMake(self.todayEarnPlatinumView.right+leftMargin*1,
                                                 0,
                                                 earnViewWidht,
                                                 earnViewHeight);
    
    self.myScrollView.contentSize = CGSizeMake(scrollViewWidth*4, self.myScrollView.height);
    
    self.menuContentView.frame = CGRectMake(leftMargin, self.myScrollView.bottom+10, scrollViewWidth, 0);
    
    CGFloat menuItemWidth = self.menuContentView.width/3;
    self.withdrawImageView.frame = CGRectMake(0, 12, 30, 30);
    self.withdrawImageView.centerX = menuItemWidth*0.5;
    self.withdrawLabel.frame = CGRectMake(0, self.withdrawImageView.bottom+6, menuItemWidth, [self.withdrawLabel textBoundingSizeWithMaxSize:CGSizeMake(menuItemWidth, 500)].height);
    self.withdrawLabel.centerX = self.withdrawImageView.centerX;
    self.withdrawButton.frame = CGRectMake(0, 0, menuItemWidth, self.withdrawLabel.bottom);
    self.withdrawButton.centerX = self.withdrawImageView.centerX;
    
    self.inviteImageView.frame = CGRectMake(0, 12, 30, 30);
    self.inviteImageView.centerX = self.menuContentView.width*0.5;
    self.inviteLabel.frame = CGRectMake(0, self.inviteImageView.bottom+6, menuItemWidth, [self.inviteLabel textBoundingSizeWithMaxSize:CGSizeMake(menuItemWidth, 500)].height);
    self.inviteLabel.centerX = self.inviteImageView.centerX;
    self.inviteButton.frame = CGRectMake(0, 0, menuItemWidth, self.inviteLabel.bottom);
    self.inviteButton.centerX = self.inviteImageView.centerX;

    self.receiveImageView.frame = CGRectMake(0, 12, 30, 30);
    self.receiveImageView.centerX = menuItemWidth*2+menuItemWidth*0.5;
    self.receiveLabel.frame = CGRectMake(0, self.receiveImageView.bottom+6, menuItemWidth, [self.receiveLabel textBoundingSizeWithMaxSize:CGSizeMake(menuItemWidth, 500)].height);
    self.receiveLabel.centerX = self.receiveImageView.centerX;
    self.receiveButton.frame = CGRectMake(0, 0, menuItemWidth, self.receiveLabel.bottom);
    self.receiveButton.centerX = self.receiveImageView.centerX;

    self.menuContentView.height = self.withdrawLabel.bottom+12;
    
    CGFloat inviteViewHeight = [self.inviteEarnView getViewHeightFromSpecialWidth:scrollViewWidth];
    self.inviteEarnView.frame = CGRectMake(leftMargin, self.menuContentView.bottom+10, scrollViewWidth, inviteViewHeight);
}
@end
